package hash_map;

import java.awt.*;

public class leetcode242 {
    public static void main(String[] args) {
        String s = "asdw";
        String t = "ssda";
        System.out.println(isAnagram(s,t));
    }

    public static boolean isAnagram(String s, String t){
        int[] record = new int[26];
        if(s.length() != t.length()) return false;
        for (int i = 0; i < s.length(); i++) {
            record[s.charAt(i) - 'a']++;
        }

        for (int i = 0; i < t.length(); i++) {
            record[t.charAt(i) - 'a']--;
        }

        for(int i = 0; i < record.length; i++){
            if(record[i] != 0) return false;
        }

        return true;
    };
}
